Human Computer Communication
1 Communicating With Different Computing Frameworks
- A runtime environment for computing
- Communicating with the runtime environment
2 Communtating with Foundational Models of Computation
2.1 Turing Machine
- A tape with cells containing symbols.
- A read/write head to access and update the tape.
- A control logic controlling the head movement and read/write operations.
2.2 Programming with TM
q0, in_symbol, q1, out_symbol, movement q0, in_symbol, q1, out_symbol, movement q0, in_symbol, q1, out_symbol, movement q0, in_symbol, q1, out_symbol, movement
where
q0
is the source statein_symbol
is whenin_symbol
is read from the current cellq1
is the state to transition toout_symbol
is the symbol to write to the current cellmovement
\(\in\{\mathrm{left}, \mathrm{right}, \mathrm{nomove}\}\)
2.3 Lambda Calculus
Simple syntax
- Variable names: \(x\), \(y\), \(\dots\)
- Function declaration: \(\lambda x. \mathrm{expression}\)
- Function invocation: \((\mathrm{expression}\ \mathrm{argument})\)
Rewriting rules
- Parameter renaming (\(\alpha\)-conversion): \(\lambda x. e \longrightarrow \lambda x'.e[x'/x]\)
- Function evaluation (\(\beta\)-reduction): \(((\lambda x.e) y)\longrightarrow e[y/x]\)
- Optimization (\(\eta\)-reduction): \(\lambda x.(f\ x)\longrightarrow f\)
2.4 Programming with LC
- \(pred = λn.λf.λx.n (λg.λh.h (g f)) (λu.x) (λu.u)\)
- \(3 = λf.λx.f (f (f x))\)
- \((pred\ 3)\)
3 General Purpose Programming Languages
3.1 The C programming language
Runtime environment
- Variables
- Functions
- Arrays
- Structures
- Direct memory access
Programming in C
void f() {
int[] numbers = {1, 2, 3, 4};
int *ptr;
= numbers + 2;
ptr ("%d\n", (*ptr));
printf}
3.2 The Python programming language
Runtime environment
- Functions with closure
- Lists, dictionaries
- Packages
Programming in Python
import os
from pprint import pprint
def show_env(keys):
= {k:os.environ[k] for k in keys}
env pprint(env)
3.3 Clojure
Runtime environment
- namespaces
- functional programming
- data transformation
Programming in Python
require '[clojure.pprint :refer [pprint])
(require '[environ.core :refer [env])
(
defn show-env [keys]
(->> keys
(map env)
(keys)
(zip hash-map)
( (pprint)))
4 High Level Languages
4.1 SQL
Runtime environment
- Relational tables
- First order logic
- Relational algebra with aggregation
Programming in SQL
WITH T_MIN(name, course_min, grade_min AS (
SELECT name, course, grade
FROM courses
WHERE (name, grade) IN (
SELECT name, MIN(grade) FROM courses
GROUP BY name
)
),name, course_max, grade_max AS (
T_MAX(SELECT name, course, grade
FROM courses
WHERE (name, grade) IN (
SELECT name, MAX(grade) FROM courses
GROUP BY name
)
)SELECT T_MIN NATURAL JOIN T_MAX;
4.2 ChatGPT
Runtime environment
- ???
Prompting in natural language
There is a table `T(name TEXT, course TEXT, grade DOUBLE)` that stores the grades of the students. Write a SQL statement that lists all the students with their lowest grade and their highest grade, and the respective courses.